package cn.dckeji.dcssm.common.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: dcssm
 * @description: 列表工具
 * @author: kenny sun
 * @create: 2019-07-18 10:17
 */
public class ListUtil {

    
    /**
    *@Description: list对象转list对象
    *@Param: [sourceList, classaz]
    *@return: java.util.List<T>
    *@Author: kenny sun
    *@Date: 2019-07-18 
    */
    public static <T>List<T> ListToList(List sourceList, Class<T> classaz) throws IllegalAccessException, InstantiationException {
        List<T> resultList = new ArrayList<>();

        if (CollectionUtil.isNotEmpty(sourceList)) {
            for (Object o1 :sourceList) {
                T object = classaz.newInstance();
                BeanUtil.copyProperties(o1,object);
                resultList.add(object);
            }
        }

        return resultList;
    }
}